#ifndef __FOCUS_SERVER_H__
#define __FOSUS_SERVER_H__

#include <map>
#include <mutex>
#include <functional>
#include "Util/util.h"
#include "jsoncpp/json.h"
#include "Network/Buffer.h"

using namespace Fdt;
class FocusServer //: public Fdt::make_shared_base<Config>
{
public:
	using ConfigFunc = std::function<bool(Json::Value &, int &result)>;

	static FocusServer *instance()
	{
		if(s_FocusServer == nullptr)
		{
			s_FocusServer = new FocusServer();
		}
		return s_FocusServer;
	}

	~FocusServer(){}
	void RegistRPC();
	bool SetMode(const Json::Value &request, const Fdt::BufferMap::Ptr &inMap, Json::Value &response, Fdt::BufferMap::Ptr &outMap);
	bool GetMode(const Json::Value &request, const Fdt::BufferMap::Ptr &inMap, Json::Value &response, Fdt::BufferMap::Ptr &outMap);
	bool SetZoomSpeedMode(const Json::Value &request, const Fdt::BufferMap::Ptr &inMap, Json::Value &response, Fdt::BufferMap::Ptr &outMap);
	bool GetZoomSpeedMode(const Json::Value &request, const Fdt::BufferMap::Ptr &inMap, Json::Value &response, Fdt::BufferMap::Ptr &outMap);
	bool ManualFocus(const Json::Value &request, const Fdt::BufferMap::Ptr &inMap, Json::Value &response, Fdt::BufferMap::Ptr &outMap);
	bool ManualZoom(const Json::Value &request, const Fdt::BufferMap::Ptr &inMap, Json::Value &response, Fdt::BufferMap::Ptr &outMap);
	bool DigitalZoom(const Json::Value &request, const Fdt::BufferMap::Ptr &inMap, Json::Value &response, Fdt::BufferMap::Ptr &outMap);
	bool OpticsZoom(const Json::Value &request, const Fdt::BufferMap::Ptr &inMap, Json::Value &response, Fdt::BufferMap::Ptr &outMap);	
	bool GetZoomInfo(const Json::Value &request, const Fdt::BufferMap::Ptr &inMap, Json::Value &response, Fdt::BufferMap::Ptr &outMap);
	bool SetFocus(const Json::Value &request, const Fdt::BufferMap::Ptr &inMap, Json::Value &response, Fdt::BufferMap::Ptr &outMap);

protected:
	FocusServer();
private:
	static FocusServer *			s_FocusServer;
	std::recursive_mutex			_mutex;
	int mode = 0;
};
#endif
